Skip to content

snapshot: serve snapshots to p2p neighbours (P3) - #102

Merged
EnzinoBB merged 6 commits into
masterfrom
feat/snapshot-p2p-provider
Oct 25, 2026
Merged

EnzinoBB merged 6 commits into
masterfrom
feat/snapshot-p2p-provider

Conversation

@EnzinoBB

Copy link
Copy Markdown
Collaborator

Step P3 of docs/plans/2026-10-25-snapshot-p2p-plan.md (design section 5). Draft: the private-network scenario comes once #101 (P2) is merged and this branch is rebased on it.

  • SnapshotProvider: answers manifest and piece requests from the newest snapshot this node built. The snapshot is verified on load (manifest, signature, seq, file sizes, chunk size at most 1 MiB and a power of two), files are kept open and read with pread; a request names a manifest entry, never a path.
  • Budget: a global token bucket (serve_rate_kbps, KB/s, burst 4 MiB), a per-peer one at half the global rate, two pieces per peer every 100 ms, at most serve_max_peers peers within 30 s, half of everything while the node is trusted; manifests once per peer every 5 s and charged to the global bucket; a 64-entry peer table.
  • Statuses: not serving (serve=off), building (nothing loaded), not synced (design 5.2: not syncing, no bootstrap round, at most 3 blocks behind a known round), busy with retry_ms, unknown.
  • SnapshotService from csnode: snapshots served by the node over HTTP #98 without the HTTP server: builds on checkpointSavedEvent while serve is on, loads the newest complete snapshot into the provider, unloads on serve=off. BlockChain::blockBytes/pruneTarget/checkpointSavedEvent, Storage::pool_bytes, the builder's streaming copy of checkpoint files (from csnode: snapshots served by the node over HTTP #98).
  • Snapshots: 512 KiB chunks by default (also --export-snapshot), no contracts file (the checkpoint carries the contract states at its block).
  • Logs: SNAPSHOT: serving block S (N files, M MB), served block S to <key>, M MB in T s, an hourly traffic summary.
  • Tests: tests/csnode/snapshot_provider_tests.cpp.

🤖 Generated with Claude Code

EnzinoBB and others added 3 commits October 25, 2026 13:13
SnapshotProvider answers manifest and piece requests from the newest snapshot
this node built: verified on load, files kept open, pieces read with pread,
a global and a per-peer token bucket, two pieces per peer every 100 ms, at
most serve_max_peers peers in 30 s, half the budget while trusted, manifests
once per peer every 5 s. SnapshotService (from #98, without the HTTP server)
builds the snapshot of each periodic checkpoint while serve is on and loads it
into the provider. Snapshots use 512 KiB chunks and no contracts file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… clock

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rve a snapshot; snapshot-p2p-serve scenario

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EnzinoBB
EnzinoBB force-pushed the feat/snapshot-p2p-provider branch from 83890a5 to 11192d1 Compare October 25, 2026 12:14
@EnzinoBB
EnzinoBB marked this pull request as ready for review October 25, 2026 12:14
EnzinoBB and others added 3 commits October 25, 2026 13:27
The service resets its failure count and is woken under its lock, and a
snapshot that does not load is removed and built again (at most five times).
The provider evicts idle keys before a downloading peer, sends one manifest
to anyone every 50 ms, counts each chunk once towards a completed download,
and asks the kernel to keep the snapshot files cached. KB/s documented.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aders exempt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es from odd nodes (mixed runs)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EnzinoBB
EnzinoBB merged commit 89387c4 into master Oct 25, 2026
115 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant